package com.jwj.controller;


import com.jwj.pojo.Post;
import com.jwj.pojo.Post_category_account;
import com.jwj.service.PostService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/post")
public class PostController {
    @Resource
    private PostService postService;
//    查所有
    @RequestMapping(value = "/all")
    public List<Post_category_account> PostAll(){
        List<Post_category_account> posts = postService.PostAll();
//        System.out.println(posts);
        return posts;
    }
//    查一个
    @RequestMapping(value = "/findOne")
    public Post OnePost(int post_id){
        System.out.println(post_id);
        Post post = postService.OnePost(post_id);
        return post;
    }
//    查状态
    @RequestMapping(value = "/findState")
    public List<Post_category_account> PostState(int state){
        List<Post_category_account> posts = postService.PostState(state);
        return posts;
    }
//    修改
    @RequestMapping(value = "/update")
    public int UpdatePost(Post post){
        int i = postService.UpdatePost(post);
        return i;
    }
//    添加
    @RequestMapping(value = "/add")
    public int AddPost(Post post){
        int i = postService.AddPost(post);
        return i;
    }
//    删除
    @RequestMapping(value = "delete")
    public int DeletePost(int post_id){
        int i = postService.DeletePost(post_id);
        System.out.println(post_id);
        return i;
    }
}